/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

import entities.Account;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.Persistence;
import javax.persistence.TypedQuery;

/**
 *
 * @author QUY_THI
 */
@Stateless
public class CheckAccount implements CheckAccountRemote, CheckAccountLocal {

    public boolean checkAccount(String accountCode) {
        boolean check = false;
        EntityManager em = Persistence.createEntityManagerFactory("eBanking-ejbPU").createEntityManager();
        String sql = "select a from Account a where a.acountCode=:acc";
        TypedQuery<Account> query = em.createQuery(sql, Account.class);
        query.setParameter("acc", accountCode);
        List<Account> resultList = query.getResultList();
        if (!resultList.isEmpty()) {
            check = true;
        }
        return check;
    }
}
